package com.building18.handler.exception;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GlobalExceptionController {
    //所有的异常全部处理
    @ExceptionHandler(MyException.class)
    public ResponseEntity<?> handleException(MyException e){
        System.out.println("全局异常拦截到了异常信息！");
        return ResponseEntity.status(e.getResult().getCode()).body(e.getResult());
    }
}
